package cn.pugle.oj.leetcode;

import cn.pugle.oj.catalog.BitProblem;
import cn.pugle.oj.catalog.Unknown;

import java.util.BitSet;

/**
 * https://leetcode.com/problems/set-matrix-zeroes/
 *
 * @author tzp
 * @since 2020/11/18
 */
public class LC73 implements BitProblem {
    public void setZeroes(int[][] matrix) {
        BitSet row = new BitSet(201);
        BitSet col = new BitSet(201);
        for (int i = 0; i < matrix.length; i++) {
            for (int j = 0; j < matrix[0].length; j++) {
                if (matrix[i][j] == 0) {
                    row.set(i);
                    col.set(j);
                }
            }
        }
        for (int i = 0; i < matrix.length; i++) {
            for (int j = 0; j < matrix[0].length; j++) {
                if (row.get(i) || col.get(j)) {
                    matrix[i][j] = 0;
                }
            }
        }
        //或者遍历bitset
//        for (int i = bitSet.nextSetBit(0); i != -1; i = bitSet.nextSetBit(i + 1)) {
//            indexes.add(i);
//        }
    }

    public static void main(String[] args) {
        System.out.println(new LC73());
    }
}
